Documentation > CMS Template API Library > Util > Paginate(List[PanelEntry],Int32)
Paginate
Separates a PanelEntry list into pages, and returns a portion of the list based on the current page number (context.PageNumber) and the given itemsPerPage. This may only be used in an output template. NOTE: Page numbers are added to filenames and URLs BEFORE any filename or url templates are run. If those templates overwrite the publish path or publish URL, then the template should add the page number using the context.PageNumber property.
public CrownPeak.CMSAPI.PaginatePanelResult Paginate(List[PanelEntry],Int32)
Returns
List containing the items appropriate for the current page
Parameters
Name | Description | Type |
---|---|---|
entireList | The list if assets to paginate. | List<PanelEntry> |
itemsPerPage | The desired number of list items per page. | System.Int32 |
Code Example
C#
List<PanelEntry> panels = asset.GetPanels("field"); PaginatePanelResult result = Util.Paginate(panels, 10); // Print links to press releases on the current page foreach(PanelEntry panel in result) { Out.WriteLine("<p>{0}</p>", panel["field"]); } // Print links to other pages foreach (PageLink link in result.PaginatedLinks) { if (link.IsCurrent()) { Out.WriteLine("{0}|", link.PageNumber); } else { Out.WriteLine("<a href=\"{0}\">{1}</a>|", link, link.PageNumber); } }